package com.hx.voice.recognition.admin.manager.service.impl;

import com.ace.cache.annotation.Cache;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hx.voice.recognition.admin.manager.entity.Menu;
import com.hx.voice.recognition.admin.manager.mapper.MenuMapper;
import com.hx.voice.recognition.admin.manager.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jack
 * @since 2019-06-12
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    @Cache(key = "permission:menu") //集成ace-cache，下次直接从redis拿
    public List<Menu> selectMenuList() {
        return super.list();
    }

    @Override
    @Cache(key = "permission:menu:u{1}")
    public List<Menu> getUserAuthorityMenuByUserId(Integer id) {
        return menuMapper.selectAuthorityMenuByUserId(id);
    }
}
